public ErrorCodes DrawDecorEnvironment(int decorId) { DecorDescription decorDescription; if (!_decors.TryGetValue(decorId, out decorDescription)) { return(ErrorCodes.ItemNotFound); } var environmentDescription = EntityEnvironment.LoadEnvironmentSql(decorDescription.definition); if (environmentDescription.Equals(default(EntityEnvironmentDescription))) { return(ErrorCodes.DefinitionHasNoEnvironment); } ErrorCodes ec; var newTurns = -1; var flipX = false; var flipY = false; if ((ec = decorDescription.FindQuaternionRotationAndMirror(ref newTurns, ref flipX, ref flipY)) != ErrorCodes.NoError) { return(ec); } _zone.DrawEnvironmentForDecor(decorDescription.GetServerPosition(), environmentDescription, newTurns, flipX, flipY); return(ErrorCodes.NoError); }
public static void CleanEnvironmentByUnit(this IZone zone, Unit unit) { var description = EntityEnvironment.LoadEnvironmentSql(unit.Definition); var turns = (int)(Math.Round(unit.Orientation, 2) / 0.25); CleanEnvironmentWithMirrorAndTurns(zone, unit.CurrentPosition, description, turns, false, false); }
private static void DrawEnvironmentByDefinitionAndPosition(this IZone zone, Unit unit) { //enviroment load var description = EntityEnvironment.LoadEnvironmentSql(unit.Definition); //draw extra environment if (description.Equals(default(EntityEnvironmentDescription))) { return; } if (description.blocksTiles == null || description.blocksTiles.Count <= 0) { return; } foreach (var tile in description.blocksTiles) { var offsetPosition = unit.CurrentPosition + tile.ToPosition(); if (!offsetPosition.IsValid(zone.Size)) { continue; } zone.Terrain.Blocks.UpdateValue(offsetPosition, bi => { return(new BlockingInfo { Obstacle = true, Height = Math.Max(bi.Height, tile.data), }); }); } }
public static void CleanBlockingByDefinition(this IZone zone, EntityDefault entityDefault) { Logger.Info($"clean blocking for definition:{entityDefault.Definition} {entityDefault.Name} on zone:{zone.Id}"); var units = zone.Units.Where(u => u.ED == entityDefault).ToList(); foreach (var unit in units) { Logger.Info($"cleaning position: {unit.CurrentPosition.ToDoubleString2D()}"); //enviroment load var description = EntityEnvironment.LoadEnvironmentSql(entityDefault.Definition); //clean environment CleanEnvironmentFromLayers(zone, unit.CurrentPosition, description); } Logger.Info($"{units.Count} {entityDefault.Name} cleaned."); }
public ErrorCodes SampleDecorEnvironment(int decorId, int range, out Dictionary <string, object> verboseResult) { ErrorCodes ec; EntityEnvironmentDescription environmentDescription; verboseResult = new Dictionary <string, object>(); DecorDescription decorDescription; if (!_decors.TryGetValue(decorId, out decorDescription)) { return(ErrorCodes.ItemNotFound); } var turns = decorDescription.FindQuaternionRotation(); if (turns == -1) { return(ErrorCodes.DecorIsNot90DegreeRotated); } if (decorDescription.scale != 1.0) { return(ErrorCodes.DecorScaled); } if ((ec = _zone.Environment.CollectEnvironmentFromPosition(decorDescription.GetServerPosition(), range, turns, out environmentDescription)) != ErrorCodes.NoError) { return(ec); } if (environmentDescription.blocksTiles == null || environmentDescription.blocksTiles.Count == 0) { return(ErrorCodes.NoError); } EntityEnvironment.WriteEnvironmentToSql(decorDescription.definition, environmentDescription); verboseResult.Add(k.blocks, environmentDescription.blocksTiles.Count); return(ec); }
/// <summary> /// Initializes the Scene class. /// </summary> protected Scene() { EntityEnvironment = new EntityEnvironment(); UIManager = new UIManager(); }
/// <summary> /// Initializes the Scene class. /// </summary> protected Scene() { EntityEnvironment = new EntityEnvironment(); UIManager = new UIManager(); }