public KillMessage(int killerId, ViewTypeId killerType, int victimId, ViewTypeId victimType) { KillerId = killerId; KillerType = killerType; VictimId = victimId; VictimType = victimType; }
public void ReplaceViewType(ViewTypeId newId) { var index = GameComponentsLookup.ViewType; var component = (ViewTypeComponent)CreateComponent(index, typeof(ViewTypeComponent)); component.id = newId; ReplaceComponent(index, component); }
public void ReplaceViewType(ViewTypeId newId) { var index = GameComponentsLookup.ViewType; var component = (Code.Scenes.BattleScene.ECS.Components.Game.ViewComponents.ViewTypeComponent)CreateComponent(index, typeof(Code.Scenes.BattleScene.ECS.Components.Game.ViewComponents.ViewTypeComponent)); component.id = newId; ReplaceComponent(index, component); }
public void ReplaceDelayedSpawn(ViewTypeId newTypeId, float newPositionX, float newPositionY, float newDirection, float newTime) { var index = GameComponentsLookup.DelayedSpawn; var component = (Code.Scenes.BattleScene.ECS.Components.Game.TimerComponents.DelayedSpawnComponent)CreateComponent(index, typeof(Code.Scenes.BattleScene.ECS.Components.Game.TimerComponents.DelayedSpawnComponent)); component.typeId = newTypeId; component.positionX = newPositionX; component.positionY = newPositionY; component.direction = newDirection; component.time = newTime; ReplaceComponent(index, component); }
public ViewObject GetViewObject(ViewTypeId typeId) { int id = (int)typeId; if (id >= 0 && id < viewObjects.Length) { return(viewObjects[id]); } else { int index = (int)ViewTypeId.Invisible; return(viewObjects[index]); } }
public static Sprite GetSprite(ViewTypeId typeId, int width = 48, int height = 48) { var dictKey = new ViewKey(typeId, width, height); if (Sprites.TryGetValue(dictKey, out var sprite)) { return(sprite); } ViewObject viewObject = ViewObjectsBase.Instance.GetViewObject(typeId); if (viewObject is SpriteObject spriteObject) { return(Sprites[dictKey] = spriteObject.sprite); } Texture2D texture; if (viewObject is AbstractLineObject lineObject) { texture = (Texture2D)lineObject.material.mainTexture; if (texture == null) { texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); texture.SetPixel(0, 0, lineObject.material.color); texture.Apply(); } } else { RuntimePreviewGenerator.PreviewDirection = Vector3.forward; RuntimePreviewGenerator.BackgroundColor = Color.clear; RuntimePreviewGenerator.OrthographicMode = true; var prefabObject = (PrefabObject)viewObject; var withoutParticles = Object.Instantiate(prefabObject.gameObject); var particleSystems = withoutParticles.GetComponentsInChildren <ParticleSystem>(); foreach (var particleSystem in particleSystems) { Object.DestroyImmediate(particleSystem); } texture = RuntimePreviewGenerator.GenerateModelPreview(withoutParticles.transform, width, height); Object.DestroyImmediate(withoutParticles); } Rect rect = new Rect(0, 0, texture.width, texture.height); return(Sprites[dictKey] = Sprite.Create(texture, rect, Vector2.zero, 100)); }
private static string GetName(ViewTypeId typeId) { return(Regex.Replace(typeId.ToString("G"), @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0")); }
public void Deconstruct(out ViewTypeId key, out ViewTypeId value) { key = this.key; value = this.value; }
public ViewKey(ViewTypeId viewTypeId, int width, int height) { Width = width; Height = height; ViewTypeId = viewTypeId; }