Пример #1
0
        public override void PlayModeGenerate(CityConfig config)
        {
            base.PlayModeGenerate(config);
            GameObjectEntity goEnt;
            var agentEntity = (goEnt = Agent.GetComponent <GameObjectEntity>()) != null
                                ? goEnt.Entity
                                : GameObjectConversionUtility.ConvertGameObjectHierarchy(Agent, World.Active);

            gameObject.AddComponent <AgentSpawnerProxy>().Value = new Model.Components.AgentSpawner
            {
//				Agent = agentEntity, //TODO this no longer work!
            };
            var spawnLocation = gameObject.AddComponent <ConnectionCoordProxy>();

            spawnLocation.Value = new ConnectionCoord()
            {
                Connection = LinkedSpawnConnection.Entity,
                Coord      = 0f,            //this value is not used
            };
            var targetLocation = gameObject.AddComponent <ConnectionTargetProxy>();

            targetLocation.Value = new ConnectionTarget()
            {
                Connection = LinkedTargetConnection.Entity,
            };
        }
Пример #2
0
        public override void Generate(CityConfig config)
        {
            base.Generate(config);
            gameObject.AddComponent <GameObjectEntity>();
            LinkedStartNode = StartNode.GenTimePointer.GetComponent <GameObjectEntity>();
#if CITY_DEBUG
            if (EndNode == null || EndNode.GenTimePointer == null)
            {
                Debug.Log(GetGameObjectPath(this.transform));
                int abc = 123;
            }
#endif
            LinkedEndNode = EndNode.GenTimePointer.GetComponent <GameObjectEntity>();
            gameObject.AddComponent <SplineProxy>().Value = ComputeBezierPoints();
            var trafficType = GetComponentInParent <RoadSegment>().GetConnectionTrafficType(this);
            gameObject.AddComponent <ConnectionTrafficProxy>().Value = new ConnectionTraffic
            {
                TrafficType = trafficType,
            };
            int conLen = ComputeLength().ToCityInt();
            gameObject.AddComponent <ConnectionLengthIntProxy>().Value = new ConnectionLengthInt
            {
                Length = conLen,
            };
            gameObject.AddComponent <ConnectionStateIntProxy>().Value = new ConnectionStateInt
            {
                EnterLen = conLen,
            };
            gameObject.AddComponent <ConnectionPullIntProxy>().Value = new ConnectionPullInt
            {
                Pull = 0,
            };
            gameObject.AddComponent <ConnectionPullQIntProxy>().Value = new ConnectionPullQInt
            {
                PullQ = 0,
            };
            gameObject.AddComponent <NetworkGroupStateProxy>().Value = new NetworkGroupState
            {
                NetworkId = -1,
            };
//			gameObject.AddComponent<NetworkGroupProxy>().Value = new NetworkGroup
//			{
//				NetworkId = -1,
//			};
            CachedSpeed = config.ConnectionBaseSpeed / config.TargetFramerate *
                          GetComponentInParent <RoadSegment>().SpeedMultiplier;
            gameObject.AddComponent <ConnectionSpeedIntProxy>().Value = new ConnectionSpeedInt
            {
                Speed = CachedSpeed.ToCityInt(),
            };

            var marker = gameObject.GetComponent <TargetMarker>();
            if (marker != null)
            {
                gameObject.AddComponent <TargetProxy>().Value = new Target
                {
                    TargetMask = (int)marker.TargetMask,
                };
            }
        }
Пример #3
0
        public override void PlayModeGenerate(CityConfig config)
        {
            base.PlayModeGenerate(config);
            if (IsIntersection())
            {
                var phaseList = new List <IntersectionPhaseBuffer>();
                int index     = 0;
                foreach (var phase in Phases)
                {
                    phaseList.Add(new IntersectionPhaseBuffer
                    {
                        StartIndex = index,
                        EndIndex   = index + phase.Connections.Length - 1,
                        Frames     = phase.Frames,
                    });
                    index += phase.Connections.Length;
                }

                gameObject.AddComponent <IntersectionPhaseBufferProxy>().SetValue(phaseList);
                var conList = Phases.SelectMany(phase => phase.Connections).Select(con => new IntersectionConBuffer()
                {
                    Connection = con.GetComponent <GameObjectEntity>().Entity,
                }).ToList();
                gameObject.AddComponent <IntersectionConBufferProxy>().SetValue(conList);
            }
        }
Пример #4
0
        public override void PlayModeGenerate(CityConfig config)
        {
            base.PlayModeGenerate(config);

            foreach (var obj in GetGenerators())
            {
                obj.PlayModeGenerate(config);
            }
        }
Пример #5
0
        public override void Generate(CityConfig config)
        {
            base.Generate(config);
            LinkedSpawnConnection  = SpawnConnection.GetComponent <GameObjectEntity>();
            LinkedTargetConnection = TargetConnection.GetComponent <GameObjectEntity>();

            gameObject.AddComponent <TimerProxy>().Value = new Model.Components.Timer
            {
                Frames    = Interval,
                TimerType = TimerType.Ticking,
            };
        }
Пример #6
0
 public override void Generate(CityConfig config)
 {
     base.Generate(config);
     if (this == NodePointer || !IsSharedNode())
     {
         gameObject.AddComponent <GameObjectEntity>();
         var node = gameObject.AddComponent <NodeProxy>();
         node.Value = new Model.Components.Node
         {
             Position = new float3(transform.position),
             Level    = 0,                  //TODO
         };
     }
 }
Пример #7
0
        public override void PlayModeGenerate(CityConfig config)
        {
            base.PlayModeGenerate(config);
            var connection  = gameObject.AddComponent <ConnectionProxy>();
            var roadSegment = GetComponentInParent <RoadSegment>();

            connection.Value = new Model.Components.Connection
            {
                StartNode = LinkedStartNode.Entity,
                EndNode   = LinkedEndNode.Entity,
                Speed     = CachedSpeed.ToCityInt(),             //TODO merge this with ConnectionSpeedInt
                Level     = roadSegment == null ? 1 : roadSegment.Level,
            };
        }
Пример #8
0
 public override void Generate(CityConfig config)
 {
     base.Generate(config);
     gameObject.AddComponent <TimerProxy>().Value = new Timer
     {
         Frames    = Interval,
         TimerType = TimerType.Ticking,
     };
     gameObject.AddComponent <TimerStateProxy>().Value = new TimerState
     {
         CountDown = Interval,
     };
     Targets = FindObjectsOfType <TargetMarker>()
               .Where(marker => (marker.TargetMask & TargetMask) != 0).ToArray();
 }
Пример #9
0
        public override void PlayModeGenerate(CityConfig config)
        {
            base.PlayModeGenerate(config);

            gameObject.AddComponent <AgentSpawnerProxy>().Value = new Model.Components.AgentSpawner
            {
                CurrentIndex = Mathf.Abs(transform.position.GetHashCode()) % Agents.Length,                 //Random.Range(0, Agents.Length), make it deterministic for testing!
            };
            gameObject.AddComponent <SpawnerBufferProxy>().SetValue(
                Agents.Select(agent => new SpawnerBuffer
            {
                Agent = GameObjectConversionUtility.ConvertGameObjectHierarchy(agent, World.Active)
            }).ToArray());

            var spawnLocation = gameObject.AddComponent <ConnectionCoordProxy>();

            spawnLocation.Value = new ConnectionCoord()
            {
                Connection = gameObject.GetComponent <GameObjectEntity>().Entity, //itself
                Coord      = 0f,                                                  //this value is not used
            };
            var targetLocation = gameObject.AddComponent <ConnectionTargetProxy>();

            targetLocation.Value = new ConnectionTarget()
            {
                Connection = Entity.Null,                 //to be filled by TargetSeeker
            };
            gameObject.AddComponent <TargetSeekerProxy>().Value = new TargetSeeker()
            {
                TargetMask      = (int)TargetMask,
                LastTargetIndex = 0,
            };
            var targets = Targets
                          .Select(marker => new TargetBuffer
            {
                Target = marker.GetComponent <GameObjectEntity>().Entity
            })
                          .ToArray();

            gameObject.AddComponent <TargetBufferProxy>().SetValue(targets);
        }
Пример #10
0
 public override void Generate(CityConfig config)
 {
     base.Generate(config);
     if (IsIntersection())
     {
         gameObject.AddComponent <GameObjectEntity>();
         gameObject.AddComponent <IntersectionProxy>().Value = new Intersection
         {
             Phase     = 0,
             PhaseType = IntersectionPhaseType.Enable,
         };
         int frames = Phases[0].Frames;
         gameObject.AddComponent <TimerProxy>().Value = new Timer
         {
             Frames    = frames,
             TimerType = TimerType.Ticking,
         };
         gameObject.AddComponent <TimerStateProxy>().Value = new TimerState
         {
             CountDown = frames,
         };
     }
 }
Пример #11
0
 public virtual void PlayModeGenerate(CityConfig config)
 {
 }
Пример #12
0
 public virtual void Generate(CityConfig config)
 {
     CachedConfig = config;
     CleanComponentProxys();
     EditorUtility.SetDirty(this);
 }