laverdet / xxscreeps

Other
71 stars 16 forks source link

Added StructureObserver type #42

Closed bastianh closed 3 years ago

bastianh commented 3 years ago

I have created a StructureObserver that works until the point where the intent is called in the processor. I have no idea how to get the target room visible for the user the next tick, maybe you have a hint ? I'll continue to look into it in the mean time .)

laverdet commented 3 years ago

I sent this response via GitHub email yesterday but it doesn't seem like it went through. Copy/pasting below: Thanks, it's exciting to see progress on this from the community. I haven't had a chance to look at the code yet but I can answer the question. I've actually thought about this in the past so I think I have a good idea. Basically you'll implement a new RoomObject which is invisible to the player and is responsible for providing vision. In the object's tick handler it will just remove itself from the room on the next tick.

You'll have to implement null LOOK and FIND constants for this, so that it's invisible to the player. The rest of it should be pretty easy to plug in to. Basically the object would provide vision, but not provide intents.

laverdet commented 3 years ago

Should checkObserveRange be called checkObserveRoom? Additionally you'd want a check of () => checkMyStructure(this.spawn, StructureObserver),. Otherwise the player could issue an observeRoom intent for non-observer structures.

bastianh commented 3 years ago

You'll have to implement null LOOK and FIND constants for this, so that it's invisible to the player. The rest of it should be pretty easy to plug in to. Basically the object would provide vision, but not provide intents.

wouldn't it make sense to not register it in the look index at all? from what I have seen in lookAt everything will be returned that is registered. I guess I'm also doing something wrong with my format, since I get some errors I can't explain ;)

laverdet commented 3 years ago

You'll have to implement null LOOK and FIND constants for this, so that it's invisible to the player. The rest of it should be pretty easy to plug in to. Basically the object would provide vision, but not provide intents.

wouldn't it make sense to not register it in the look index at all? from what I have seen in lookAt everything will be returned that is registered. I guess I'm also doing something wrong with my format, since I get some errors I can't explain ;)

Oh yeah definitely we don't want them in the look index. If I remember correctly the room code unconditionally adds all objects to LOOK and FIND so I was just saying you'd have to add a null check to skip that part.

bastianh commented 3 years ago

I have updated the MR and according to the tests it's working .)

I had to add a few casts regarding the look types, not sure if that was the correct way to go

laverdet commented 3 years ago

Thanks! Hopefully I can get this up and running on xxworld today