public static Entity AddAbility(Entity agent, EntityManager manager, GhostPrefabCollectionComponent ghostCollection) { //var ghostId = NetAgentGhostSerializerCollection.FindGhostType<ShieldSnapshotData>(); var ghostId = 2; var prefab = manager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value; var ability = manager.Instantiate(prefab); var agentGhostId = manager.GetComponentData <GhostComponent>(agent).ghostId; Usable usable; KeyCodeComp keycode; OwningPlayer player; Shield shield; shield.strength = 10; shield.damage = 10; keycode.Value = KeyCode.S; usable.inuse = false; usable.canuse = true; player.Value = agent; player.PlayerId = manager.GetComponentData <AgentComponent>(agent).PlayerId; manager.SetComponentData <Usable>(ability, usable); manager.SetComponentData <KeyCodeComp>(ability, keycode); manager.SetComponentData <Shield>(ability, shield); manager.SetComponentData <OwningPlayer>(ability, player); return(ability); }
public static Entity AddAbility(Entity agent, EntityManager manager, GhostPrefabCollectionComponent ghostCollection) { //var ghostId = NetAgentGhostSerializerCollection.FindGhostType<SwordSnapshotData>(); var ghostId = 3; var prefab = manager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value; var ability = manager.Instantiate(prefab); var agentGhostId = manager.GetComponentData <GhostComponent>(agent).ghostId; Cooldown cooldown; Usable usable; KeyCodeComp keycode; OwningPlayer player; Sword sword; cooldown.timer = 0; cooldown.duration = 1; sword.damage = 10; keycode.Value = KeyCode.Space; usable.inuse = false; usable.canuse = true; player.Value = agent; player.PlayerId = manager.GetComponentData <AgentComponent>(agent).PlayerId; //trans.Value = new float3(100000,1,0); // so it starts invisible manager.SetComponentData <Cooldown>(ability, cooldown); manager.SetComponentData <Usable>(ability, usable); manager.SetComponentData <KeyCodeComp>(ability, keycode); manager.SetComponentData <Sword>(ability, sword); manager.SetComponentData <OwningPlayer>(ability, player); //manager.SetComponentData<Translation>(ability, trans); // initialize hitboxes ghostId = 6; prefab = manager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value; var swordHitbox = manager.Instantiate(prefab); manager.SetComponentData <OwningPlayer>(swordHitbox, player); manager.SetComponentData <AssociatedEntity>(swordHitbox, new AssociatedEntity { Value = ability }); manager.SetComponentData <Damage>(swordHitbox, new Damage { Value = sword.damage }); manager.SetComponentData <Disableable>(swordHitbox, new Disableable { disabled = false }); manager.AddBuffer <Hit>(swordHitbox); var hitboxBuffer = manager.AddBuffer <HitboxElement>(ability).Reinterpret <Entity>(); hitboxBuffer.Add(swordHitbox); return(ability); }
public static Entity AddAbility(Entity agent, float cooldown_length, float speed, float distance, float3 dir, KeyCode key, EntityManager manager, GhostPrefabCollectionComponent ghostCollection) { //var ghostId = NetAgentGhostSerializerCollection.FindGhostType<DashSnapshotData>(); var ghostId = 1; var prefab = manager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value; var ability = manager.Instantiate(prefab); var agentGhostId = manager.GetComponentData <GhostComponent>(agent).ghostId; Cooldown cooldown; Usable usable; Dash dash; KeyCodeComp keycode; OwningPlayer player; cooldown.timer = 0; cooldown.duration = cooldown_length; dash.speed = speed; dash.distance_traveled = 0; dash.max_distance = distance; dash.dir = dir; keycode.Value = key; //This key is set by keycodesystem, not here. usable.inuse = false; usable.canuse = true; player.Value = agent; player.PlayerId = manager.GetComponentData <AgentComponent>(agent).PlayerId; manager.SetComponentData <Cooldown>(ability, cooldown); manager.SetComponentData <Usable>(ability, usable); manager.SetComponentData <KeyCodeComp>(ability, keycode); manager.SetComponentData <Dash>(ability, dash); manager.SetComponentData <OwningPlayer>(ability, player); return(ability); }