Let you change per axis model scale in /model, model scale saves for bots.

This commit is contained in:
UnknownShadow200 2017-11-12 23:26:10 +11:00
parent 6644e21425
commit b84753ec6a
4 changed files with 42 additions and 22 deletions

View File

@ -108,6 +108,9 @@ namespace MCGalaxy.Bots {
public byte RotY { get; set; }
public byte BodyX { get; set; }
public byte BodyZ { get; set; }
public float ScaleX { get; set; }
public float ScaleY { get; set; }
public float ScaleZ { get; set; }
public void FromBot(PlayerBot bot) {
Name = bot.name; Level = bot.level.name;
@ -121,6 +124,7 @@ namespace MCGalaxy.Bots {
X = bot.Pos.X; Y = bot.Pos.Y; Z = bot.Pos.Z;
RotX = bot.Rot.RotY; RotY = bot.Rot.HeadX;
BodyX = bot.Rot.RotX; BodyZ = bot.Rot.RotZ;
ScaleX = bot.ScaleX; ScaleY = bot.ScaleY; ScaleZ = bot.ScaleZ;
}
public void ApplyTo(PlayerBot bot) {
@ -136,22 +140,7 @@ namespace MCGalaxy.Bots {
bot.cur = CurInstruction; bot.curJump = CurJump;
bot.ClickedOnText = ClickedOnText; bot.DeathMessage = DeathMessage;
}
public BotProperties Copy() {
BotProperties copy = new BotProperties();
copy.DisplayName = DisplayName; copy.Name = Name;
copy.Level = Level; copy.Skin = Skin;
copy.Model = Model; copy.Color = Color;
copy.AI = AI; copy.Kill = Kill; copy.Hunt = Hunt;
copy.CurInstruction = CurInstruction; copy.CurJump = CurJump;
copy.ClickedOnText = ClickedOnText; copy.DeathMessage = DeathMessage;
copy.X = X; copy.Y = Y; copy.Z = Z;
copy.RotX = RotX; copy.RotY = RotY;
copy.BodyX = BodyX; copy.BodyZ = BodyZ;
return copy;
bot.ScaleX = ScaleX; bot.ScaleY = ScaleY; bot.ScaleZ = ScaleZ;
}
}
}

View File

@ -41,7 +41,8 @@ namespace MCGalaxy.Commands.CPE {
}
protected override void SetBotData(Player p, PlayerBot bot, string model) {
model = GetModel(model);
bool changedAxisScale;
model = ParseModel(p, bot, model, out changedAxisScale);
Entities.UpdateModel(bot, model);
Player.Message(p, "You changed the model of bot " + bot.ColoredName + " %Sto a &c" + model);
@ -49,7 +50,8 @@ namespace MCGalaxy.Commands.CPE {
}
protected override void SetPlayerData(Player p, Player who, string model) {
model = GetModel(model);
bool changedAxisScale;
model = ParseModel(p, who, model, out changedAxisScale);
Entities.UpdateModel(who, model);
if (p != who) {
@ -64,14 +66,40 @@ namespace MCGalaxy.Commands.CPE {
Server.models.Remove(who.name);
}
Server.models.Save();
if (!changedAxisScale) return;
if (who.ScaleX != 0 || who.ScaleY != 0 || who.ScaleZ != 0) {
Server.modelScales.AddOrReplace(who.name, who.ScaleX + " " + who.ScaleY + " " + who.ScaleZ);
} else {
Server.modelScales.Remove(who.name);
}
Server.modelScales.Save();
}
static string GetModel(string model) {
static string ParseModel(Player dst, Entity entity, string model, out bool changedAxisScale) {
if (model.Length == 0) model = "humanoid";
model = model.ToLower();
model = model.Replace(':', '|'); // since many assume : is for scale instead of |.
changedAxisScale = false;
if (model.CaselessStarts("x ")) {
changedAxisScale = true;
return ParseModelScale(dst, entity, model, "X scale", ref entity.ScaleX);
} else if (model.CaselessStarts("y ")) {
changedAxisScale = true;
return ParseModelScale(dst, entity, model, "Y scale", ref entity.ScaleY);
} else if (model.CaselessStarts("z ")) {
changedAxisScale = true;
return ParseModelScale(dst, entity, model, "Z scale", ref entity.ScaleZ);
}
return model;
}
static string ParseModelScale(Player dst, Entity entity, string model, string argName, ref float value) {
string[] bits = model.SplitSpaces();
CommandParser.GetReal(dst, bits[1], argName, ref value, 0, 3);
return entity.Model;
}
public override void Help(Player p) {
Player.Message(p, "%T/Model [name] [model] %H- Sets the model of that player.");

View File

@ -423,10 +423,11 @@ namespace MCGalaxy.Commands.CPE {
SendEditHelp(p, arg); return;
}
def.InventoryOrder = order;
def.InventoryOrder = order == def.BlockID ? -1 : order;
BlockDefinition.UpdateOrder(def, global, level);
BlockDefinition.Save(global, level);
Player.Message(p, "Set inventory order for {0} to {1}", blockName, value);
Player.Message(p, "Set inventory order for {0} to {1}", blockName,
order == def.BlockID ? "default" : order.ToString());
return;
default:
Player.Message(p, "Unrecognised property: " + arg); return;

View File

@ -109,7 +109,7 @@ namespace MCGalaxy.Maths {
bb = bb.Expand(-1); // adjust the model AABB inwards slightly
float scale;
if (!Utils.TryParseDecimal(scaleStr, out scale)) return bb;
if (!Utils.TryParseDecimal(scaleStr, out scale)) scale = 1.0f;
if (scale < 0.25f) scale = 0.25f;
float maxScale = model.CaselessEq("chibi") ? 3 : 2;
if (scale > maxScale) scale = maxScale;
@ -122,6 +122,8 @@ namespace MCGalaxy.Maths {
bb.Min.X = (int)(bb.Min.X * scaleX); bb.Max.X = (int)(bb.Max.X * scaleX);
bb.Min.Y = (int)(bb.Min.Y * scaleY); bb.Max.Y = (int)(bb.Max.Y * scaleY);
bb.Min.Z = (int)(bb.Min.Z * scaleZ); bb.Max.Z = (int)(bb.Max.Z * scaleZ);
Server.s.Log("AABB: " + bb);
return bb;
}