protected EntityAttribute(Entity entity, TValueType baseValue, TValueType maxValue, EntityAttributes attributeType) { Entity = entity; BaseValue = baseValue; MaxValue = maxValue; AttributeType = attributeType; }
public static Type GetType(EntityAttributes attribute) { switch (attribute) { case EntityAttributes.CurrentHealth: return(typeof(float)); case EntityAttributes.BaseMoveSpeed: return(typeof(float)); case EntityAttributes.CurrentMoveSpeed: return(typeof(float)); case EntityAttributes.IsAggroed: return(typeof(bool)); case EntityAttributes.NextWaypoint: return(typeof(Vector3)); case EntityAttributes.CurrentTarget: return(typeof(Transform)); case EntityAttributes.CurrentTargetPosition: return(typeof(Vector3)); case EntityAttributes.CurrentRotationSpeed: return(typeof(float)); case EntityAttributes.CurrentDirection: return(typeof(Vector3)); default: return(typeof(float)); } }
public void AddMapping(AttributeDefinition mapping) { if (mapping is EntityAttribute) { var m = mapping as EntityAttribute; //if (!EntityAttributes.Contains(m)) //{ // EntityAttributes.Add(m); //} foreach (var a in EntityAttributes) { if (a.Name.Equals(m.Name) && a.IfcEntityAttribute.Equals(m.IfcEntityAttribute)) { return; } } EntityAttributes.Add(m); } else if (mapping is BbTypeAttribute) { var n = mapping as BbTypeAttribute; foreach (var s in BbTypeAttributes) { if (s.Name.Equals(n.Name)) { return; } } BbTypeAttributes.Add(n); } }
public GameObject Spawn(int ID, int EntityID, Vector3 pos, Quaternion quat) { GameObject obj = null; if (ID == 1) { obj = Instantiate(EnemyBear, pos, quat); } else { obj = Instantiate(EnemyBunny, pos, quat); } EntityAttributes ea = obj.GetComponent <EntityAttributes>(); ea.ID = ID; ea.EntityID = EntityID; if (enemyArray.ContainsKey(ea.EntityID) == true) { enemyArray[ea.EntityID].SetActive(false); Destroy(enemyArray[ea.EntityID]); enemyArray.Remove(ea.EntityID); } this.enemyArray.Add(EntityID, obj); return(obj); }
public Student(string firstName, string lastName, IEnumerable <int> scores) { _scores.AddRange(scores); Attributes = new EntityAttributes(); FirstName = firstName; LastName = lastName; }
/// <summary> /// If team is -1 then the team will be autoassigned and the spawnBounds will be the spawn bounds of the /// assigned team. /// </summary> /// <param name="name">Name of the new entity</param> /// <param name="team">Team of the new entity or -1</param> /// <param name="attributes">Attributes of the entity</param> /// <param name="spawnBounds">Spawn bounds - ignored if team is -1</param> /// <param name="callback">Optional callback for after the first world created with entity in it</param> public EntityAddedMutation(string name, int team, EntityAttributes attributes, Rect2 spawnBounds, Action <Entity> callback) { Name = name; Team = team; Attributes = attributes; SpawnBounds = spawnBounds; Callback = callback; }
internal void ModifyAttribute(TValueType baseValue, TValueType currentValue, TValueType minValue, TValueType maxValue, EntityAttributes attributeType) { AttributeType = attributeType; BaseValue = baseValue; MaxValue = maxValue; MinValue = minValue; CurrentValue = currentValue; }
public Sensor(Guid sensorId, string displayName, decimal currentValue) { Attributes = new EntityAttributes(); SensorId = sensorId; DisplayName = displayName; CurrentValue = currentValue; }
public virtual EntityAttributes GetEntityAttributes() { var attributes = new EntityAttributes(); attributes["minecraft:attack_damage"] = new EntityAttribute { Name = "minecraft:attack_damage", MinValue = 0, MaxValue = 16, Value = AttackDamage }; attributes["minecraft:absorption"] = new EntityAttribute { Name = "minecraft:absorption", MinValue = 0, MaxValue = float.MaxValue, Value = HealthManager.Absorption }; attributes["minecraft:health"] = new EntityAttribute { Name = "minecraft:health", MinValue = 0, MaxValue = 20, Value = HealthManager.Hearts }; attributes["minecraft:knockback_resistance"] = new EntityAttribute { Name = "minecraft:knockback_resistance", MinValue = 0, MaxValue = 1, Value = 0 }; attributes["minecraft:luck"] = new EntityAttribute { Name = "minecraft:luck", MinValue = -1025, MaxValue = 1024, Value = 0 }; attributes["minecraft:fall_damage"] = new EntityAttribute { Name = "minecraft:fall_damage", MinValue = 0, MaxValue = float.MaxValue, Value = 0 }; attributes["minecraft:follow_range"] = new EntityAttribute { Name = "minecraft:follow_range", MinValue = 0, MaxValue = 2048, Value = 16 }; return(attributes); }
private void OnAttributeChanged(EntityAttributes attributeType) { if (attributeType == EntityAttributes.Health || attributeType == EntityAttributes.MaxHealth) { health.Ratio = unit.HealthRatio; } else if (attributeType == EntityAttributes.Power || attributeType == EntityAttributes.MaxPower) { mainResource.Ratio = Mathf.Clamp01((float)unit.Mana / unit.MaxMana); } }
public void DeleteAttribute(string n) { var a = EntityAttributes.FirstOrDefault(b => b.Name.ToLower() == n.ToLower()); if (a != null) { EntityAttributes.Remove(a); } //_attributeMappingList.RemoveAt(n); //return _attributeMappingList; }
public void SetBackpack(MsgSCBackpack msg) { GameSceneManager gs = GetComponent <GameSceneManager>(); GameObject obj = GetPlayerOjb(gs.userID); if (obj != null) { EntityAttributes ea = obj.GetComponent <EntityAttributes>(); ea.SetBackpack(msg); } }
// Simple getters. public object GetAttribute(EntityAttributes attribute) { try { return(Attributes[attribute]); } catch (Exception) { Debug.Log("Soft attribute not found:"); Debug.Log(attribute); return(null); } }
protected void InitializeControllers() { BattleController = GetComponent <BattleController>(); AnimationController = GetComponent <AnimationController>(); MovementController = GetComponent <MovementController>(); EntityAttributes = GetComponent <EntityAttributes>(); ProgressBarControllers = GetComponents <ProgressBarController>().ToDictionary(b => b.progressBarName, b => b); if (ProgressBarControllers != null && ProgressBarControllers.ContainsKey("HealthBar")) { HealthBarController = ProgressBarControllers["HealthBar"]; } }
private void LoadAttributes(PropertyInfo property) { AttributeExtractor extractor = new AttributeExtractor(property); if (extractor.UnmappedAttribute != null) { return; } if (extractor.EntityAttribute != null) { EntityAttributes.Add(extractor.EntityAttribute); } if (extractor.FormulaAttribute != null) { FormulaAttributes.Add(extractor.FormulaAttribute); } if (extractor.ColumnAttribute != null) { if (!ColumnAttributes.Contains(extractor.ColumnAttribute)) { ColumnAttributes.Add(extractor.ColumnAttribute); } if (extractor.ForeignKeyAttribute != null) { ColumnForeignKeys[extractor.ColumnAttribute] = extractor.ForeignKeyAttribute; } if (extractor.PrimaryKeyAttribute != null) { ColumnPrimaryKeys[extractor.ColumnAttribute] = extractor.PrimaryKeyAttribute; } } if (!extractor.PropertyIsMapped()) { /* * We should warn the user if they have a property in this class that is not mapped, as * this may have been unintentional. They should used an UnmappedAttribute if they wish to * express that the property was left unmapped on purpose. */ Logger.Warn(MethodBase.GetCurrentMethod(), $"Property {property.Name} of class {entityType.Name} is not mapped explicitly, use an UnmappedAttribute if this was intentional."); } }
// Setter for soft attribute that checks input value against expected type for that attribute. public void SetAttribute(EntityAttributes attribute, object newValue) { if (!object.ReferenceEquals(newValue.GetType(), EntityAttributeTypes.GetType(attribute))) { Debug.Log("Tried to update SoftAttribute with invalid type."); Debug.Log("Attribute:"); Debug.Log(attribute); Debug.Log("Value:"); Debug.Log(newValue); Debug.Log("Expected type:"); Debug.Log(EntityAttributeTypes.GetType(attribute)); return; } Attributes[attribute] = newValue; }
public bool IsEnemyGameObject(GameObject obj) { EntityAttributes ea = obj.GetComponent <EntityAttributes>(); if (ea == null) { return(false); } if (enemyArray.ContainsKey(ea.EntityID) == false) { return(false); } return(true); }
public GameObject CreatePlayer(int userID, int entityID, Vector3 pos, Quaternion quat, bool actor) { GameObject obj = null; EntityAttributes ea = null; //Other players if (actor != true) { obj = Instantiate(otherplayer, pos, quat); ea = obj.GetComponent <EntityAttributes>(); ea.ID = userID; ea.ID = entityID; if (playerArray.ContainsKey(ea.ID) == true) { Destroy(playerArray[ea.ID]); playerArray.Remove(ea.ID); } playerArray.Add(ea.ID, obj); return(obj); } // Current player obj = Instantiate(player, pos, quat); ea = obj.GetComponent <EntityAttributes>(); ea.ID = userID; ea.EntityID = entityID; CameraFollower cam = Camera.main.GetComponent <CameraFollower>(); if (cam != null) { cam.SetCameraPosition(obj.transform.position); cam.target = obj.transform; cam.SetOffset(); } playerArray.Add(ea.ID, obj); return(obj); }
public void Write(EntityAttributes attributes) { if (attributes == null) { WriteVarInt(0); return; } WriteVarInt(attributes.Count); foreach (EntityAttribute attribute in attributes.Values) { Write(attribute.Name); Write(attribute.MinValue); Write(attribute.Value); Write(attribute.MaxValue); } }
public EntityAttributes ReadEntityAttributes() { var attributes = new EntityAttributes(); int count = ReadVarInt(); for (int i = 0; i < count; i++) { EntityAttribute attribute = new EntityAttribute { Name = ReadString(), MinValue = ReadFloat(), Value = ReadFloat(), MaxValue = ReadFloat(), }; attributes[attribute.Name] = attribute; } return(attributes); }
public GameObject CreateTrap(int ID, int EntityID, Vector3 pos, Quaternion quat) { GameObject obj = null; if (ID == 1) { obj = Instantiate(trapPin, pos, quat); } else { obj = Instantiate(trapSpeed, pos, quat); } EntityAttributes ea = obj.GetComponent <EntityAttributes>(); ea.ID = ID; ea.EntityID = EntityID; addTrapArray(ea.EntityID, obj); return(obj); }
public override void Initialize(int ownerUniqueID) { this.ownerUniqueID = ownerUniqueID; identifier = PStrings.entityController; input = new EntityInput(); input.InitializeDefaults(); attributes = new EntityAttributes(); attributes.InitializeDefaults(); state = new EntityState(); state.InitializeDefaults(); entityData = (EntityData)GridData.GetExtensible(ownerUniqueID); rigidbody = entityData.gameObject.GetComponent <Rigidbody>(); weaponController = entityData.gameObject.GetComponent <WeaponController>(); if (weaponController != null) { weaponController.Initialize(entityData); } waypointManager = (WaypointManagerData)entityData.GetExtension(PStrings.waypointManager); pathfindManager = (PathfindManagerData)entityData.GetExtension(PStrings.pathfindManager); state.rotationCurrent = Metrics.OrientationFromDirection[(int)entityData.orientation]; }
public EntityAttributeInt(Entity entity, int baseValue, int maxValue, EntityAttributes attributeType) : base(entity, baseValue, maxValue, attributeType) { CurrentValue = BaseValue; }
protected Command() { Attributes = new EntityAttributes(); }
public DynamicEntityAttribute DynamicEntityAttribute() { return((DynamicEntityAttribute)EntityAttributes.Single(x => x is DynamicEntityAttribute)); }
public SensorReading() { Attributes = new EntityAttributes(); }
public EntityAttributeFloat(Entity entity, float baseValue, float maxValue, EntityAttributes attributeType) : base(entity, baseValue, maxValue, attributeType) { CurrentValue = BaseValue; }
protected DomainEvent() { Attributes = new EntityAttributes(); }
public Sensor() { Attributes = new EntityAttributes(); }